import React, {Component} from 'react'
import {imgUrl} from "../../../common/config/wxConfig";

import './cateShow.scss'


class CateShow extends Component {
    constructor(props) {
        super(props);
    }

    onClickCard = (e) => {
        this.props.searchCateById(e.target.getAttribute('cateId'))
    }

    render() {
        return (
            <div className='cate-show-block'>
                {
                    this.props.data.map((data, i) => (
                        <div className='cate-r' key={i}>
                            <div className='cate-c'>
                                <div className="cate-show-card" cateid={data[0].id} onClick={this.onClickCard}>
                                    <img cateid={data[0].id} src={`${imgUrl}${data[0].logo}`} alt=""/>
                                    <span cateid={data[0].id}>{data[0].name}</span>
                                </div>
                            </div>
                            <div className='cate-c'>
                                <div className="cate-show-card" cateid={data[1].id} onClick={this.onClickCard}>
                                    <img cateid={data[1].id} src={`${imgUrl}${data[1].logo}`} alt=""/>
                                    <span cateid={data[1].id}>{data[1].name}</span>
                                </div>
                            </div>
                        </div>
                    ))
                }
            </div>
        )
    }
}

export default CateShow;